<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/common/commonCss.jsp"></jsp:include>
<jsp:include page="/common/commonJs.jsp"></jsp:include>
<script type="text/javascript"
	src="${basePath }commonJs/quinn_commons.js"></script>
<title>首页</title>

<script type="text/javascript">
	$(document).ready(function() {
		initTable("form1","table1","foot1",callback1);
	})

	function initTable(formId, tableId, footId, callback) {
		var form = $("#" + formId);
		var pagebean = new PageBean(form);
		pagebean.setTableId(tableId);
		pagebean.setFootId(footId);
		pagebean.setCallback(callback);
		setPagebeanObj(pagebean);
		pagebean.doPage();
	}

	function callback1(data) {
		cb(data,"1");
	}

	function callback2(data) {
		cb(data,"2");
	}
	function callback3(data) {
		cb(data,"3");
	}
	function callback4(data) {
		cb(data,"4");
	}
	function callback5(data) {
		cb(data,"5");
	}
	
/* 	
	
	
	
	
	
	
	
	
	
 */
	function cb(data,tableId){
		
		
	
		$.each(data,function(ind,obj){
			
			obj = emptyJson(obj);
			
			var os ="";
			if(obj.orderStatus=="1"){
				os="未付款";
			}else if(obj.orderStatus=="2"){
				os="已付款";
			}else if(obj.orderStatus=="3"){
				os="已预付";
			}else if(obj.orderStatus=="4"){
				os="购物车";
			}else if(obj.orderStatus=="5"){
				os="取消";
			}else if(obj.orderStatus=="6"){
				os = "已预付";
			}else if(obj.orderStatus=="7"){
				os = "草稿";
			}
			
			var link ="";
			
			if(obj.orderStatus=="4"){
				link="${basePath}order/shopCart.shtml?id="+obj.pkOrderId+"&isParty=false";
			}else{
				link="${basePath}order/detail.shtml?id="+obj.pkOrderId;
			}
			
			
			var button = "";
			if(obj.orderStatus=="1" || obj.orderStatus=="4"){
				button = "<input type=\"button\" value=\"取消\" class=\"btn_l \" onclick=\"cancelOrder('"+obj.pkOrderId+"','"+tableId+"')\">";
			}else if(obj.orderStatus=="2"&&(obj.orderType=="1"||obj.orderType=="5")){
				button = "<input type=\"button\" value=\"退货\" class=\"btn_l \">";
			}
			
			var paymethod = "";
			
			var payTime = "";
			
			if(obj.orderStatus=="1"||obj.orderStatus=="4"){
				paymethod="-";
				payTime="-";
			}else{
				paymethod=obj.payMethod;
				payTime = obj.time2;
			}
			
			
			var trHtm="<tr>";
			trHtm+="<td class=\"lv\"><a href=\""+link+"\">"+obj.pkOrderId+"</a></td>";
			trHtm+="<td>普通商品</td>";
			trHtm+="<td>￥"+obj.amount+"</td>";
			trHtm+="<td>"+paymethod+"</td>";
			trHtm+="<td>"+payTime+"</td>";
			trHtm+="<td>"+obj.cusName+"</td>";
			trHtm+="<td>"+obj.operator+"</td>";
			trHtm+="<td>"+os+"</td>";
			if(obj.orderStatus!="3"){
				trHtm+="<td>"+button+"</td>";
			}
			trHtm+="</tr>";
			
			$("#table"+tableId).find("tr:eq("+ind+")").after(trHtm);
		});
	}
	
	function cancelOrder(id,no){
		$.messager.confirm("提示", "确认要取消吗?", function(d){
			$.ajax({
				url:"${basePath}order/cancelOrderAjax.shtml",
				type:"post",
				dataType:"json",
				data:{
					id:id
				},async:false,
				success:function(data){
					if(data){
						initTable("form"+no, "table"+no, "foot"+no, eval("callback"+no));
					}
				},error : function(XMLHttpRequest) {
					ajaxError(XMLHttpRequest);
				}
			});
		});
	}
</script>
</head>
<body class="bg">


	<div class="content m_auto">
		<div class="content_l mt10">
			<ul>
			<shiro:hasPermission name="goods/list.shtml">
					<li><a href="${basePath }goods/list.shtml"><i class="nav_icon_k"></i><br>商品</a></li>
				</shiro:hasPermission>
				<shiro:hasPermission name="order/shopCart.shtml">
					<li><a href="${basePath }order/shopCart.shtml"><i class="nav_icon_l"></i><br>购物篮</a></li>
				</shiro:hasPermission>
				<shiro:hasPermission name="order/list.shtml">
					<li class="content_hover"><a href="${basePath }order/list.shtml"><i
						class="nav_icon_m"></i><br>订单</a></li>
				</shiro:hasPermission>
			</ul>
		</div>
		<div class="content_r mt10">
			<div class="p20">
				<h1 class="f16">
					<input type="text" placeholder="搜索订单号" class="iput_t"><input
						type="button" class="btn ml10" value="搜 索">
				</h1>

				<form action="${basePath }order/paginate.shtml" id="form1"
					method="post">
					<input type="hidden" name="pageSize" value="10"> <input
						type="hidden" name="pageNo" value="1"> <input
						type="hidden" name="orderStatus" value="4">
						<input
						type="hidden" name="onlyMe" value="true">
				</form>
				<form action="${basePath }order/paginate.shtml" id="form2"
					method="post">
					<input type="hidden" name="pageSize" value="10"> <input
						type="hidden" name="pageNo" value="1"> <input
						type="hidden" name="orderStatus" value="1">
				</form>
				<form action="${basePath }order/paginate.shtml" id="form3"
					method="post">
					<input type="hidden" name="pageSize" value="10"> <input
						type="hidden" name="pageNo" value="1"> <input
						type="hidden" name="orderStatus" value="2">
				</form>
				<form action="${basePath }order/paginate.shtml" id="form4"
					method="post">
					<input type="hidden" name="pageSize" value="10"> <input
						type="hidden" name="pageNo" value="1"> <input
						type="hidden" name="orderStatus" value="3">
				</form>
				<form action="${basePath }order/paginate.shtml" id="form5"
					method="post">
					<input type="hidden" name="pageSize" value="10"> <input
						type="hidden" name="pageNo" value="1">
				</form>

				<div class="tab_normal mt10">
					<ul id="tab_a" class=" fixed">
						<li onclick="initTable('form1','table1','foot1',callback1);">购物车</li>
						<li onclick="initTable('form2','table2','foot2',callback2);">未付款</li>
						<li onclick="initTable('form3','table3','foot3',callback3);">已付款</li>
						<li onclick="initTable('form4','table4','foot4',callback4);">派对未结算</li>
						<li onclick="initTable('form5','table5','foot5',callback5);">全部</li>
					</ul>
					<ul id="tab_conbox_a" class="fixed">
						<li class="p10" style="display: list-item;">
							<table class="table" id="table1">
								<tbody>
									<tr>
										<th>订单</th>
										<th>商品类型</th>
										<th>金额</th>
										<th>付款方式</th>
										<th>交易时间</th>
										<th>顾客信息</th>
										<th>操作员</th>
										<th>订单状态</th>
										<th>操作</th>
									</tr>
								</tbody>
							</table>
							<div class="page fr m10" id="foot1"></div>
						</li>
						<li class="p10" style="display: list-item;">
							<table class="table" id="table2">
								<tbody>
									<tr>
										<th>订单</th>
										<th>商品类型</th>
										<th>金额</th>
										<th>付款方式</th>
										<th>交易时间</th>
										<th>顾客信息</th>
										<th>操作员</th>
										<th>订单状态</th>
										<th>操作</th>
									</tr>
								</tbody>
							</table>
							<div class="page fr m10" id="foot2"></div>
						</li>
						<li class="p10" style="display: none;">
							<table class="table" id="table3">
								<tbody>
									<tr>
										<th>订单</th>
										<th>商品类型</th>
										<th>金额</th>
										<th>付款方式</th>
										<th>交易时间</th>
										<th>顾客信息</th>
										<th>操作员</th>
										<th>订单状态</th>
										<th>操作</th>
									</tr>
								</tbody>
							</table>
							<div class="page fr m10" id="foot3"></div>
						</li>
						<li class="p10" style="display: none;">
							<table class="table" id="table4">
								<tbody>
									<tr>
										<th>订单</th>
										<th>商品类型</th>
										<th>金额</th>
										<th>付款方式</th>
										<th>交易时间</th>
										<th>顾客信息</th>
										<th>操作员</th>
										<th>订单状态</th>
									</tr>
								</tbody>
							</table>
							<div class="page fr m10" id="foot4"></div>
						</li>
						<li class="p10" style="display: none;">
							<table class="table mt10" id="table5">
								<tbody>
									<tr>
										<th>订单</th>
										<th>商品类型</th>
										<th>金额</th>
										<th>付款方式</th>
										<th>交易时间</th>
										<th>顾客信息</th>
										<th>操作员</th>
										<th>订单状态</th>
										<th>操作</th>
									</tr>
								</tbody>
							</table>
							<div class="page fr m10" id="foot5"></div>
						</li>
					</ul>
				</div>

			</div>
		</div>
	</div>


	<!---弹出层--->
	<div id="e" class="easyui-window" title="特殊折扣设置"
		data-options="modal:true,closed:true,iconCls:'icon-save'"
		style="width: 500px; height: 300px; position: relative;">
		<div class="margin_auto w300 pt30">
			<ul class="ul_label f14">
				<li><label>折扣率：</label><input type="text" class="iput_t"></li>
				<li><label>经理密码：</label><input type="text" class="iput_t"></li>
			</ul>
		</div>
		<div class="btm_btn btm_bg">
			<dl>
				<dd>
					<input type="button" class="btn" onClick="javascript:alert('ok')"
						value="确定">
				</dd>
				<dd>
					<input type="button" class="btn" onClick="javascript:alert('ok')"
						value="返回">
				</dd>
			</dl>
		</div>
	</div>
	<!---弹出层--->


</body>
</html>